﻿@model IEnumerable<SisGAC.Models.Artigo>

<h2>@ViewBag.Title</h2>

<p>
    @Html.ActionLink("Submeter Artigo", "Cadastro", new { idcongresso = ViewBag.CongressoId })

@if (ViewBag.Coordenador == true)
{
   @Html.ActionLink("Distribuir Artigos", "Distribuir", "Artigos")
    @Html.ActionLink("Classificar Artigos", "Classificar", new { idcongresso = ViewBag.CongressoId })
    
}
    </p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Titulo)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.DataCriacao)           
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Area)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Autores)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Situacao)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Titulo)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DataCriacao)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Area.Nome)
        </td>
        <td>
            @if (item.Autores.Count > 0) {
            @Html.DisplayFor(modelItem => item.Autores.First().Nome)
            }
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Situacao)
        </td>
        <td>
            @Html.ActionLink("Detalhes", "Details", new { id=item.ArtigoId })
            @if (ViewBag.Coordenador == true || (item.CadastradoPor.UserName == User.Identity.Name && item.Congresso.DataFimSubmissao > DateTime.Today)) {
                @Html.ActionLink("Editar", "Cadastro", new { id = item.ArtigoId })
                @Html.ActionLink("Excluir", "Delete", new { id=item.ArtigoId })
            }
        </td>
    </tr>
}

</table>
